package com.talos.ums.dal.mysql.userorganization;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.userorganization.vo.UmsUserOrganizationPageReqVO;
import com.talos.ums.dal.dataobject.userorganization.UmsUserOrganizationDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户组织关系表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsUserOrganizationMapper extends BaseMapperX<UmsUserOrganizationDO> {

    default PageResult<UmsUserOrganizationDO> selectPage(UmsUserOrganizationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsUserOrganizationDO>()
                .eqIfPresent(UmsUserOrganizationDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UmsUserOrganizationDO::getOrganizationId, reqVO.getOrganizationId())
                .eqIfPresent(UmsUserOrganizationDO::getUserCode, reqVO.getUserCode())
                .eqIfPresent(UmsUserOrganizationDO::getOrganizationCode, reqVO.getOrganizationCode())
                .eqIfPresent(UmsUserOrganizationDO::getAllParentsCode, reqVO.getAllParentsCode())
                .betweenIfPresent(UmsUserOrganizationDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsUserOrganizationDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsUserOrganizationDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsUserOrganizationDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(UmsUserOrganizationDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsUserOrganizationDO::getModifierId, reqVO.getModifierId())
                .eqIfPresent(UmsUserOrganizationDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsUserOrganizationDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsUserOrganizationDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(UmsUserOrganizationDO::getId));
    }

}
